package cn.topkinson.rocketmq.seckill.service;

import cn.topkinson.rocketmq.seckill.common.RocketConstant;
import cn.topkinson.rocketmq.seckill.entity.dto.OrderMsg;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author huangzihao
 * @Date 2021/1/18 14:28
 */
@Service
public class SeckillService {

    @Autowired
    private ProducerService producerService;

    public String createOrder(String productId, String userId) {
        return producerService.sendTx(RocketConstant.TOPIC_ORDER, JSON.toJSONString(new OrderMsg(productId, userId)));
    }
}
